package zhuyun.code.launcheractivity.model

import io.reactivex.observers.DisposableObserver
import zhuyun.code.launcheractivity.model.data.*

/**
 * @author: Administrator
 * @date: 2021/11/17
 */
object NetworkRequest {
    fun verificationCode(userName:String, sendType:Int, isPhone:Int, code:String, subscriber:DisposableObserver<BaseResponse<String>>){
        val map = HashMap<String,String>()
        map["UserName"] = userName
        map["SendType"] = sendType.toString()
        map["IsPhone"] = isPhone.toString()
        map["code"] = code
        val observable = HttpMethods.instance.httpApi.verificationCode(map)
        HttpMethods.toSubscribe(observable,subscriber)
    }

    fun phoneRegister(userName: String, pwd:String,code: String,countryId:Int,
                      userTypeId:Int,headUrl:String,appToken:String,nickName:String,
                      inviterUserId:String,subscriber: DisposableObserver<BaseResponse<String>>){
        val map = HashMap<String,String>()
        map["UserName"] = userName
        map["Pwd"] = pwd
        map["code"] = code
        map["CountryId"] = countryId.toString()
        map["UserTypeId"] = userTypeId.toString()
        map["HeadUrl"] = headUrl
        map["AppToken"] = appToken
        map["NickName"] = nickName
        map["InviterUserId"] = inviterUserId
        val observable = HttpMethods.instance.httpApi.phoneRegister(map)
        HttpMethods.toSubscribe(observable,subscriber)
    }

    fun mobileLogin(userName:String, pwd:String, countryId: Int, subscriber: DisposableObserver<BaseResponse<MobileLoginBean>>){
        val map = HashMap<String,String>()
        map["UserName"] = userName
        map["Pwd"] = pwd
        map["CountryId"] = countryId.toString()
        val observable = HttpMethods.instance.httpApi.mobileLogin(map)
        HttpMethods.toSubscribe(observable,subscriber)
    }

    fun getHomeData(subscriber: DisposableObserver<BaseResponse<HomeBean>>){
        val map = HashMap<String,String>()
        val observable = HttpMethods.instance.httpApi.getHomePageData(map)
        HttpMethods.toSubscribe(observable,subscriber)
    }

    fun getFriendDetails(friendUserId:String,observer: DisposableObserver<BaseResponse<FriendDetailsBean>>){
        val map = HashMap<String,String>()
        map["FriendUserId"] = friendUserId
        val observable = HttpMethods.withHeader(map).instance.httpApiChat.getFriendDetails(map)
        HttpMethods.toSubscribe(observable,observer)
    }

    fun getCommonFriends(otherUserId:String, take:Int, observer: DisposableObserver<BaseResponse<List<RecommendFriendsBean>>>){
        val map = HashMap<String,String>()
        map["OtherUserId"] = otherUserId
        map["Take"] = "$take"
        val observable = HttpMethods.instance.httpApiChat.getCommonFriends(map)
        HttpMethods.toSubscribe(observable,observer)
    }

    fun getMyDynamicList(isBusiness:Int,page:Int,pageSize:Int,visitUserId:String,beginTime:String,endTime:String,observer: DisposableObserver<BaseResponse<List<CircleListBean>>>){
        val map = HashMap<String,String>()
        map["IsBusiness"] = "$isBusiness"
        map["page"] = "$page"
        map["pagesize"] = "$pageSize"
        map["VisitUserId"] = visitUserId
        map["begintime"] = beginTime
        map["endtime"] = endTime
        val observable = HttpMethods.withHeader(map).instance.httpApiChat.getMyDynamicList(map)
        HttpMethods.toSubscribe(observable,observer)

    }

    fun getDetailByUserId(visitUserId:String,observer: DisposableObserver<BaseResponse<GetDetailByUserIdBean>>){
        val map = HashMap<String,String>()
        map["VisitUserId"] = visitUserId
        val observable = HttpMethods.withHeader(map).instance.httpApiChat.getDetailByUserId(map)
        HttpMethods.toSubscribe(observable,observer)
    }

    fun applyAddFriend(coverUserId:String, msgContent:String, isOpen:Int,isLookMyCircle:Int,remarks:String,companyName:String
                       ,companyPhone:String,companyEmail:String,sourceId:Int,observer: DisposableObserver<BaseResponse<CommonRequestBean>>){
        val map = HashMap<String,String>()
        map["CoverUserId"] = coverUserId
        map["MsgContent"] = msgContent
        map["IsOpen"] = "$isOpen"
        map["IsLookMyCircle"] = "$isLookMyCircle"
        map["Remarks"] = remarks
        if(companyName.isNotEmpty()){
            map["CompanyName"] = companyName
        }
        map["CompanyPhone"] = companyPhone
        map["CompanyEmail"] = companyEmail
        map["SourceId"] = "$sourceId"
        val observable = HttpMethods.withHeader(map).instance.httpApiChat.applyAddFriend(map)
        HttpMethods.toSubscribe(observable,observer)
    }

    //分页动态列表
    fun getPostDynamic(keyWords:String, mainClassId:Int, countryId:Int,orderBy:Int,page:Int,pageSize:Int,observer: DisposableObserver<BaseResponse<List<PostDynamicListData>>>){
        val map = HashMap<String,String>()
        if(keyWords.isNotEmpty()){
            map["KeyWords"] = keyWords
        }
        map["MainClassId"] = "$mainClassId"
        map["CountryId"] = "$countryId"
        map["OrderBy"] = "$orderBy"
        map["page"] = "$page"
        map["pageSize"] = "$pageSize"
        val observable = HttpMethods.instance.httpApi.getPostDynamic(map)
        HttpMethods.toSubscribe(observable,observer)
    }

    fun getCountry(subscriber: DisposableObserver<BaseResponse<List<CountryBean>>>){
        val map = HashMap<String,String>()
        val observable = HttpMethods.instance.httpApi.getCountry(map)
        HttpMethods.toSubscribe(observable,subscriber)
    }

    fun getFollowMain(isMore:Int,page:Int,pageSize:Int,subscriber: DisposableObserver<BaseResponse<List<FollowMainBean>>>){
        val map = HashMap<String,String>()
        map["IsMore"] = "$isMore"
        map["page"] = "$page"
        map["pagesize"] = "$pageSize"
        val observable = HttpMethods.instance.httpApi.getFollowMain(map)
        HttpMethods.toSubscribe(observable,subscriber)
    }

}